package holiday_demo.classAndInterface.demo09;
//类作为成员变量类型的演示
//其实任何一种类型，都可以作为成员变量
public class Hero {
    private String name;//英雄名称
    private int age;//年龄
    private Weapon weapon;//英雄的武器

    public Hero() {
    }

    public Hero(String name, int age, Weapon weapon) {
        this.name = name;
        this.age = age;
        this.weapon = weapon;
    }
    public void attack(){
        System.out.println("年龄为"+this.age+",名字叫做："+this.name+"的英雄正在利用"+this.weapon.getCode()+"攻击敌人！");
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Weapon getWeapon() {
        return weapon;
    }

    public void setWeapon(Weapon weapon) {
        this.weapon = weapon;
    }
}
